package be.fomp.jeve.model.caching;

import be.fomp.jeve.model.exceptions.JEveCacheLoadingException;
import be.fomp.jeve.model.exceptions.JEveCacheStoringException;

public interface Cacher {

	/**
	 * This method will cache the Object to a specific location.<br />
	 * How this caching happens is defined by the implementation.<br />
	 * The location is a string of format: <pre><path>/<filename></pre><br />
	 * This will allow for the Object factory to store to a default path and in a default filename.<br />
	 * Where the root path is is fully up to the implementation of this interface.<br />
	 * <br />
	 * The implementation must throw a JEveCacheStoringException when something goes wrong with the cache
	 * and preferably specify what went wrong.
	 * 
	 * @param jeveObject A Jeve Object, actually any serializable object
	 * @param location The path where the object will be stored.
	 * @throws JEveCacheStoringException When storing into the cache failed.
	 */
	void store(Object jeveObject, String location) throws JEveCacheStoringException;
	
	/**
	 * This method load an Object from a specific location.<br />
	 * How this loading happens is defined by the implementation.<br />
	 * The location is a string of format: <pre><path>/<filename></pre><br />
	 * This will allow for the Object factory to load from a default path and in a default filename.<br />
	 * Where the root path is is fully up to the implementation of this interface.<br />
	 * <br />
	 * The implementation must throw a JEveCacheLoadingException when something goes wrong with the cache
	 * and preferably specify what went wrong.
	 * 
	 * @param location The path where the object will be stored.
	 * @throws JEveCacheLoadingException when loading from the cache failed.
	 * @return jeveObject A Jeve Object, actually any serializable object
	 */
	Object load(String location) throws JEveCacheLoadingException;
	
}
